<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('ads', function (Blueprint $table) {
            $table->unsignedBigInteger('id')->primary();
            $table->string('name')->nullable()->default('')->comment('广告名称');
            $table->unsignedBigInteger('user_id')->default(0)->comment('创建用户ID')->index('user');
            $table->unsignedBigInteger('agent_user_id')->nullable()->default(0)->comment('绑定代理用户ID')->index('agent_user');
            $table->string('redirect_url')->nullable()->default('')->comment('广告跳转地址');
            $table->enum('cate',['NORMAL','PRIVATE'])->nullable()->default('NORMAL')->comment('广告类型NORMAL全局PRIVATE私有' );
            $table->string('cover_url')->nullable()->default('')->comment('广告封面');
            $table->unsignedBigInteger('price')->nullable()->default(0)->comment('价格');
            $table->dateTime('expired_at')->nullable()->comment('广告有效期');
            $table->timestamps();
            $table->softDeletes();
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('ads');
    }
}
